export default {
  props: {
    to: String | Object
  },
  render(h) {
    const path = this.to.path ? this.to.path : this.to;

    return h('a', {
      attrs: {
        href: path
      },
      on: {
        click: (event) => {
          if (this.$router.data.current) {
            this.$router.data.current = path;
            if (this.$router.mode === "hash") {
              location.hash = `${path}`;
            } else {
              history.pushState({}, '', path);
            }
            event.preventDefault();
          } else {
            console.error("This is Error");
          }
        }
      }
    }, this.$slots.default)
  }
};
